package com.leoman.plz_p.adapter;

import android.content.Context;
import android.view.View;

import com.leoman.plz_p.R;
import com.leoman.plz_p.module.bean.BookListBean;

import cn.com.corelib.utils.adapter.BaseAdapterHelper;
import cn.com.corelib.utils.adapter.normal.QuickAdapter;

/**
 * Created by guoh on 2018/7/8.
 */
public class PointAdapter extends QuickAdapter<BookListBean> {

    public PointAdapter(Context context) {
        super(context, R.layout.item_point);
    }

    @Override
    protected void convert(BaseAdapterHelper helper, BookListBean item, int position) {

        switch (item.getStatus()){
            case 1:
                helper.setBackgroundRes(R.id.iv_project_progress,R.mipmap.icon_zero_to_four);
                break;
            case 2:
                helper.setBackgroundRes(R.id.iv_project_progress,R.mipmap.icon_one_to_one);
                break;
        }

        helper.setTag(R.id.tv_project_video,position)
                .setTag(R.id.tv_project_test,position)
                .setOnClickListener(R.id.tv_project_video, new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        if (onItemClick!=null){
                            onItemClick.onVideoClick(Integer.parseInt(view.getTag().toString()));
                        }
                    }
                })
                .setOnClickListener(R.id.tv_project_test, new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        if (onItemClick!=null){
                            onItemClick.onTestClick(Integer.parseInt(view.getTag().toString()));
                        }
                    }
                });


        helper.setText(R.id.tv_project_name,item.getName());
        switch (item.getVideo()){
            //微课视频 1显示按钮（灰色） 2不显示3显示已点击（蓝色）4显示合格
            case "1":
//                helper.setBackgroundRes(R.id.tv_project_video,R.drawable.class_off_style);
                break;
            case "2":
                helper.setVisible(R.id.ll_video_layout,false);
                break;
            case "3":
//                helper.setBackgroundRes(R.id.tv_project_video,R.drawable.class_on_style);
                break;
            case "4":
//                helper.setBackgroundRes(R.id.tv_project_video,R.drawable.class_compete_style);
                break;
        }
    }

    public void setOnItemClick(PointAdapter.onItemClick onItemClick) {
        this.onItemClick = onItemClick;
    }

    private onItemClick onItemClick;

    public interface onItemClick{
        void onVideoClick(int position);
        void onExamClick(int position);
        void onTestClick(int position);
    }
}